//
//  HYJSTableViewCell.m
//  自定义collectionView
//
//  Created by apple on 15-1-15.
//  Copyright (c) 2015年 apple. All rights reserved.
//

#import "HYJSTableViewCell.h"//会员介绍

@implementation HYJSTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = RGBA(236, 236, 236, 1);
        
        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, __MainScreen_Width, 194)];
        [self addSubview:view];
        view.backgroundColor = [UIColor whiteColor];
        view.layer.borderColor = [UIColor lightGrayColor].CGColor;
        view.layer.borderWidth = 0.5;
        
        float height = 5;
        UILabel * titleLab = [[UILabel alloc]initWithFrame:CGRectMake(10, height, 80, 30)];
        [self addSubview:titleLab];
        titleLab.text = @"会员介绍";
        titleLab.font = [UIFont fontWithName:nil size:15];
        
        [self reloadTable];
       
    }
    return self;
}
- (void)reloadTable
{
    
    MNReportData *tableData = [MNReportData alloc];
    
    NSMutableArray *colWidthArray = [NSMutableArray arrayWithObjects:@55,@90,@80,@75,nil];
    
    tableData.colWidthArray = colWidthArray;
    
    
    tableData.headerDatas = [self withHeaderArray:@[@"会员级别",@"加入条件",@"权益",@"升降级规则"]];
    tableData.bodyDatas =[self withBodyArray:@[@[@"会员",@"注册即可成为注册会员",@"50元起送，100元包邮，商品评论权，购物的积分",@""],@[@"会员+",@"会员可添加，暂时不分类，全段不显示",@"特权自定义",@""],@[@"企业会员",@"选择企业会员登陆",@"显示企业会员，享受特定会员折扣",@""],@[@"会员+",@"会员可添加，暂时不分类，全段不显示",@"特权自定义",@""]]];
    tableData.autoFitHeaderHeight = YES;    //表头自适应行高
    tableData.autoFitBodyHeight = YES;
    tableData.headerBackgroundColor = @"#FFFFFFFF";
    tableData.headerTextColor = @"#00000000";
    
    report = [[MNReportView alloc] initWithFrame:CGRectMake(10, 35, 300,  150) dataSource:tableData];
    [self addSubview:report];
}


-(NSArray *)withHeaderArray:(NSArray *)array
{
    NSMutableArray * arr = [array mutableCopy];
    NSMutableArray * row = [NSMutableArray array];
    NSMutableArray * roww = [NSMutableArray array] ;
    for (int i=0; i<arr.count; i++) {
        
        MNReportGrid * grid = [MNReportGrid alloc];
        
        grid.text = [NSString stringWithFormat:@"%@", arr[i]];
        grid.fontSize =10.0;
        grid.bold = YES;    //bold属性要设置fontSize才能起作用.
        [roww addObject:grid];
    }
    [row addObject:roww];
    return row;
}

-(NSArray *)withBodyArray:(NSArray *)array
{
    NSMutableArray * arr = [array mutableCopy];
    NSMutableArray * row = [NSMutableArray array];
    NSMutableArray * roww ;
    for (int i=0; i<arr.count; i++) {
        roww = [NSMutableArray array];
        for (int j = 0; j < [(NSArray *)(arr[i]) count]; j++) {
            
            
            MNReportGrid * grid = [MNReportGrid alloc];
            
            grid.text = [NSString stringWithFormat:@"%@", arr[i][j]];
            grid.fontSize =10.0;
            grid.bold = YES;//bold属性要设置fontSize才能起作用.
            [roww addObject:grid];
        }
        [row addObject:roww];
    }
    return row;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
